#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;
const int M = 1e9 + 7;

int n, m;
int t[N], v[N], color[N];

struct Edge
{
    int to, next;
} e[N << 1];

int head[N], idx = 1;

void add_edge(int u, int v)
{
    e[idx].to = v;
    e[idx].next = head[u];
    head[u] = idx++;
}
void clear_graph()
{
    memset(head, -1, sizeof(head));
    memset(e, 0, sizeof(e));
    memset(color, 0, sizeof(color));
    idx = 1;
}

bool dfs(int u, int c = 1)
{
    color[u] = c;
    for (int i = head[u]; ~i; i = e[i].next)
    {
        int j = e[i].to;
        if (color[j] == c)
            return false;
        if (color[j] == 0)
        {
            if (!dfs(j, 3 - c))
                return false;
        }
    }
    return true;
}

bool bipartite()
{
    for (int i = 1; i <= n; i++)
    {
        if (!color[i])
        {
            if (!dfs(i))
                return false;
        }
    }
    return true;
}

int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    int T;
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        clear_graph();
        ll delta = 0;
        for (int i = 1; i <= n; i++)
            cin >> v[i];
        for (int i = 1; i <= n; i++)
            cin >> t[i];

        for (int i = 1; i <= n; i++)
            delta += (v[i] - t[i]);
        for (int i = 1; i <= m; i++)
        {
            int u, v;
            cin >> u >> v;
            add_edge(u, v), add_edge(v, u);
        }

        
        if (delta & 1)
        {
            cout << "NO" << endl;
        }
        else
        {
            if (!bipartite()) cout << "YES" << endl;
            else {
                ll sum1 = 0, sum2 = 0;
                for (int i = 1; i <= n; i++) {
                    if (color[i] == 1) sum1 += (t[i] - v[i]);
                    else sum2 += (t[i] - v[i]);
                }
                if (sum1 == sum2) cout << "YES" << endl;
                else cout << "NO" << endl;
            }
        }
    }
    return 0;
}